package com.googlecode.mailnet.math.distribution;

import com.googlecode.mailnet.math.RandomUtil;

/**
 * Uniform distribution that generates numbers from <tt>min</tt> inclusively to <tt>max</tt> exclusively.
 *
 * @author Iskander Akishev
 */
class UniformDistribution implements Distribution {

	private final double min, max;

	UniformDistribution(double min, double max) {
        if (min > max) {
            throw new IllegalArgumentException(String.format("min (%f) is greater than max (%f)", min, max));
        }
        this.min = min;
		this.max = max;
	}

    public double getValue() {
		return min + RandomUtil.nextDouble() * (max - min);
	}
}
